<?php

namespace Loan\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class LoanController extends AbstractActionController
{
    protected $loanTable;
    protected $loan;

    public function getLoanTable()
    {
        if (!$this->loanTable) {
            $sm = $this->getServiceLocator();
            $this->loanTable = $sm->get('Loan\Model\LoanTable');
        }
        return $this->loanTable;
    }

    public function indexAction()
    {
        $this->loan = $this->getLoanTable()->fetchAll();
        $view = new ViewModel(array(
            'loan' => $this->loan
        ));
        return $view;
    }
}